/*!
 * Remark Material (http://getbootstrapadmin.com/remark)
 * Copyright 2017 amazingsurge
 * Licensed under the Themeforest Standard Licenses
 */

!function(global,factory){if("function"==typeof define&&define.amd)define("/Section/Menubar",["exports","jquery","Component"],factory);else if("undefined"!=typeof exports)factory(exports,require("jquery"),require("Component"));else{var mod={exports:{}};factory(mod.exports,global.jQuery,global.Component),global.SectionMenubar=mod.exports}}(this,function(exports,_jquery,_Component2){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _jquery2=babelHelpers.interopRequireDefault(_jquery),_Component3=babelHelpers.interopRequireDefault(_Component2),$BODY=(0,_jquery2.default)("body"),$HTML=(0,_jquery2.default)("html"),Hoverscroll=function(){function Hoverscroll($el){babelHelpers.classCallCheck(this,Hoverscroll),this.$el=$el,this.api=null,this.init()}return babelHelpers.createClass(Hoverscroll,[{key:"init",value:function(){this.api=this.$el.asHoverScroll({namespace:"hoverscorll",direction:"vertical",list:".site-menu",item:"> li",exception:".site-menu-sub",fixed:!1,boundary:100,onEnter:function(){},onLeave:function(){}}).data("asHoverScroll")}},{key:"update",value:function(){this.api&&this.api.update()}},{key:"enable",value:function(){this.api||this.init(),this.api&&this.api.enable()}},{key:"disable",value:function(){this.api&&this.api.disable()}}]),Hoverscroll}(),_class=function(_Component){function _class(){var _ref;babelHelpers.classCallCheck(this,_class);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];var _this=babelHelpers.possibleConstructorReturn(this,(_ref=_class.__proto__||Object.getPrototypeOf(_class)).call.apply(_ref,[this].concat(args)));return _this.$menuBody=_this.$el.children(".site-menubar-body"),_this.$menu=_this.$el.find("[data-plugin=menu]"),_this.$menuBody.length>0?(_this.initialized=!0,_this.hoverscroll=new Hoverscroll(_this.$menuBody),_this.hoverscroll.enable(),_this.type="open",_this):(_this.initialized=!1,babelHelpers.possibleConstructorReturn(_this))}return babelHelpers.inherits(_class,_Component),babelHelpers.createClass(_class,[{key:"initialize",value:function(){$HTML.removeClass("css-menubar").addClass("js-menubar"),this.change(this.type)}},{key:"process",value:function(){(0,_jquery2.default)(".site-menu-sub").on("touchstart",function(e){e.stopPropagation()}).on("ponitstart",function(e){e.stopPropagation()})}},{key:"getMenuApi",value:function(){return this.$menu.data("menuApi")}},{key:"setMenuData",value:function(){this.getMenuApi().outerHeight=this.$el.outerHeight()}},{key:"update",value:function(){this.hoverscroll.update()}},{key:"change",value:function(type){this.initialized&&(this.reset(),this[type](),this.setMenuData())}},{key:"animate",value:function(doing){var _this2=this,callback=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};$BODY.addClass("site-menubar-changing"),doing.call(this),this.$el.trigger("changing.site.menubar");var menuApi=this.getMenuApi();menuApi&&menuApi.refresh(),setTimeout(function(){callback.call(_this2),$BODY.removeClass("site-menubar-changing"),_this2.update(),_this2.$el.trigger("changed.site.menubar")},500)}},{key:"reset",value:function(){$BODY.removeClass("site-menubar-hide site-menubar-unfold")}},{key:"hide",value:function(){this.animate(function(){$BODY.removeClass("site-menubar-unfold").addClass("site-menubar-hide")}),this.type="hide"}},{key:"open",value:function(){this.animate(function(){$BODY.removeClass("site-menubar-hide").addClass("site-menubar-unfold")},function(){this.triggerResize()}),this.type="open"}}]),_class}(_Component3.default);exports.default=_class});